<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="docgen-resources/docgen.css" type="text/css">
  <meta name="generator" content="FreeMarker Docgen (DocBook 5)">
  <title>
    FreeMarker Manual - Containers
  </title>
    <script type="text/javascript" src="docgen-resources/jquery.js"></script>
    <script type="text/javascript" src="docgen-resources/linktargetmarker.js"></script>
</head>
<body>

    <div class="navigation">
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="pgui.html">Programmer's Guide</a>
            <b>></b>
          <a href="pgui_datamodel.html">The Data Model</a>
            <b>></b>
          Containers
</span>    </div>
    <div class="bookmarks">
<span class="bookmarks">Bookmarks:
<a href="alphaidx.html">Alphabetical Index</a>, <a href="gloss.html">Glossary</a>, <a href="ref.html">Reference</a>, <a href="app_faq.html">FAQ</a>, <a href="api/index.html">Java API</a>, <a href="../index.html">FreeMarker Home</a></span>    </div>
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="pgui_datamodel_method.html"><span class="hideA">Next page: </span>Methods</a></div><div class="pagerButton"><a href="pgui_datamodel_scalar.html">Previous page</a></div><div class="pagerButton"><a href="pgui_datamodel.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    </div>

<div id="mainContent">

  
  
  
  
  <h1 class="rank_section1"
        id="pageTopTitle">
<a name="pgui_datamodel_parent"></a>Containers  </h1>
    
    <div class="toc">
      <p>
        <b>
            Page Contents
        </b>
      </p>
      
  <ul class="noMargin">
      <li style="padding-bottom: 0.5em"><i><a href="#docgen_afterTheTOC">Intro.</a></i></li>
      <li>
        <a href="#autoid_32">Hashes</a>
      </li>
      <li>
        <a href="#autoid_33">Sequences</a>
      </li>
      <li>
        <a href="#autoid_34">Collections</a>
      </li>
  </ul>
    </div>
    <a name="docgen_afterTheTOC"></a>
    
<p>These are hashes, sequences, and collections.</p>
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="autoid_32"></a>Hashes  </h2>


          

          <p>Hashes are java objects that implement
          <tt style="color: #A03D10">TemplateHashModel</tt> interface.
          <tt style="color: #A03D10">TemplateHashModel</tt> contains two methods:
          <tt style="color: #A03D10">TemplateModel get(String key)</tt>, which returns the
          subvariable of the given name, and <tt style="color: #A03D10">boolean
          isEmpty()</tt>, which indicates if the hash has zero
          subvariable or not. The <tt style="color: #A03D10">get</tt> method returns null
          if no subvariable with the given name exists.</p>

          <p>The <tt style="color: #A03D10">TemplateHashModelEx</tt> interface extends
          <tt style="color: #A03D10">TemplateHashModel</tt>. It adds methods by which <a href="ref_builtins_hash.html#ref_builtin_values">values</a> and <a href="ref_builtins_hash.html#ref_builtin_keys">keys</a> built-ins can enumerate the
          subvariables of the hash.</p>

          <p>The commonly used implementation is
          <tt style="color: #A03D10">SimpleHash</tt>, which implements
          <tt style="color: #A03D10">TemplateHashModelEx</tt>. Internally it uses a
          <tt style="color: #A03D10">java.util.Hash</tt> to store the subvariables.
          <tt style="color: #A03D10">SimpleHash</tt> has methods by which you can add and
          remove subvariable. These methods should be used to initialize the
          variable directly after its creation.</p>

          <p>Containers are immutable within FTL. That is, you can't add,
          replace or remove the subvariables they contain.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="autoid_33"></a>Sequences  </h2>


          

          <p>Sequences are java objects that implement
          <tt style="color: #A03D10">TemplateSequenceModel</tt>. It contains two methods:
          <tt style="color: #A03D10">TemplateModel get(int index)</tt> and <tt style="color: #A03D10">int
          size()</tt>.</p>

          <p>The commonly used implementation is
          <tt style="color: #A03D10">SimpleSequence</tt>. It uses internally a
          <tt style="color: #A03D10">java.util.List</tt> to store its subvariables.
          <tt style="color: #A03D10">SimpleSequence</tt> has methods by which you can add
          subvariables. These methods should be used to populate the sequence
          directly after its creation.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="autoid_34"></a>Collections  </h2>


          

          <p>Collections are java objects that implement the
          <tt style="color: #A03D10">TemplateCollectionModel</tt> interface. That interface
          has one method: <tt style="color: #A03D10">TemplateModelIterator iterator()</tt>.
          The <tt style="color: #A03D10">TemplateModelIterator</tt> interface is similar to
          <tt style="color: #A03D10">java.util.Iterator</tt>, but it returns
          <tt style="color: #A03D10">TemplateModels</tt> instead of
          <tt style="color: #A03D10">Object</tt>-s, and it can throw
          <tt style="color: #A03D10">TemplateModelException</tt>s.</p>

          <p>The commonly used implementation is
          <tt style="color: #A03D10">SimpleCollection</tt>.</p>
          
</div>

    <div class="navigation">
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="pgui_datamodel_method.html"><span class="hideA">Next page: </span>Methods</a></div><div class="pagerButton"><a href="pgui_datamodel_scalar.html">Previous page</a></div><div class="pagerButton"><a href="pgui_datamodel.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="pgui.html">Programmer's Guide</a>
            <b>></b>
          <a href="pgui_datamodel.html">The Data Model</a>
            <b>></b>
          Containers
</span>    </div>
    </div>

<table border=0 cellspacing=0 cellpadding=0 width="100%">
    <tr>
      <td colspan=2><img src="docgen-resources/img/none.gif" width=1 height=8 alt=""></td>
    <tr>
      <td align="left" valign="top"><span class="smallFooter">
            FreeMarker Manual -- For FreeMarker 2.3.16
            <br>
          HTML generated: 2009-12-08 08:38:54 GMT
      </span></td>
      <td align="right" valign="top"><span class="smallFooter">
          <a href="http://www.xmlmind.com/xmleditor/">
            <img src="docgen-resources/img/xxe.gif" alt="Edited with XMLMind XML Editor">
          </a>
      </span></td>
    </tr>
</table>
  <!-- Put pre-loaded images here: -->
  <div style="display: none">
    <img src="docgen-resources/img/linktargetmarker.gif" alt="Here!" />
  </div>
</body>
</html>

